<?php
    require_once( 'includes/common.inc.php' );
    
    $userManager = new UserManager();
    $authorizer  = new Authorizer();
    
    $isDataValid = isset( $_POST['login'] ) && isset( $_POST['password'] ) &&
                   !empty( $_POST['login'] ) && !empty( $_POST['password'] ) &&
                   $userManager->isUserExist( $_POST['login'], $_POST['password'] );
                                  
    if ( $isDataValid )
    {
        $login = DataBase::getInstance()->quote( $_POST['login'] );
        $authorizer->userLogin( $login );
    }
    else
    {
        header( "Location: /php/login.php?auth=error" );
    }
?>